<?php
/**
 * Created by PhpStorm.
 * User: zsl
 * Date: 2019-10-02
 * Time: 14:28
 */

namespace App\Controller;

use App\Service\UploadService;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**
 * Class UploadFileController
 * @package App\Controller
 * @Route("/upload/")
 */
class UploadFileController
{
    /**
     * @var UploadService
     */
    private $uploadService;

    /**
     * UploadFileController constructor.
     * @param UploadService $uploadService
     */
    public function __construct(UploadService $uploadService)
    {
        $this->uploadService = $uploadService;
    }

    /**
     * @param Request $request //
     * @Route("upload")
     * @return int
     */
    public function upload(Request $request)
    {
        $files = $request->files;
        $file  = $files->get('mp4');
        assert($file instanceof UploadedFile);


        return $this->uploadService->uploadFile($file);
    }
}